<template>
  <el-dialog v-model="show" :show-close="false" @open="handleOpen" align-center class="app-dialog">
    <div class="app-dialog__header">
      <div class="app-dialog__title">
        <div style="margin-right: 16px">{{ title }}</div>
        <div class="app-dialog__fit_title">
          <slot name="fit_title"></slot>
        </div>
      </div>
      <el-icon @click="show = false" style="cursor: pointer;">
        <Close />
      </el-icon>
    </div>

    <div class="app-dialog__body" v-loading="loading">
      <slot></slot>
    </div>

    <div class="app-dialog__footer">
      <slot name="footer"></slot>
    </div>
  </el-dialog>
</template>
<script setup>
const show = defineModel({ type: Boolean })

const props = defineProps({
  title: String,
  loading: Boolean
})
</script>
<style lang="scss" scoped>
.app-dialog__header {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 2px 2px 0 0;
  color: #1d2129;
  height: 55px;
  padding: 16px 24px;
}

.app-dialog__title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;

  .app-dialog__fit_title {
    color: #999;
    font-size: 14px;
    font-weight: 500;
  }
}

.app-dialog__body {
  min-height: 100px;
  max-height: calc(100vh - 142px);
}

.app-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  border-radius: 2px 2px 0 0;
  color: #1d2129;
  height: 55px;
  padding: 10px 16px;
}
</style>

<style lang="scss">
.app-dialog {
  padding: 0;
  border-radius: 0;
  overflow: hidden;

  .el-dialog__header {
    display: none;
  }
}
</style>
